﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Win32;
using System.Xml;
using System.Configuration;

namespace music_player
{
    /// <summary>
    /// settings.xaml 的交互逻辑
    /// </summary>
    public partial class settings : Window
    {
        public settings()
        {
            InitializeComponent();
            HasStart.IsChecked = Properties.Settings.Default.HasStartMusic;
        }


        private void Button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog op = new Microsoft.Win32.OpenFileDialog();
            op.Filter = "音乐文件(*.mp3)|*.mp3";
            op.RestoreDirectory = true;
            op.ShowDialog();
            if(op.FileName!=null)
            {
                startMusicName.Text = op.FileName;
                Properties.Settings.Default.StartMusic = op.FileName;
                Properties.Settings.Default.Save();
                
            }
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            OpenFileDialog op = new Microsoft.Win32.OpenFileDialog();
            op.Filter = "图片(*.jpg)|*.jpg";
            op.RestoreDirectory = true;
            op.ShowDialog();
            if (op.FileName != null)
            {
                BackgroundName.Text = op.FileName;
                Properties.Settings.Default.Background = op.FileName;
                Properties.Settings.Default.Save();
            }
        }

        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            if(HasStart.IsChecked==true)
            {
                Properties.Settings.Default.HasStartMusic = true;
                Properties.Settings.Default.Save();
            }
            else
            {
                Properties.Settings.Default.HasStartMusic = false;
                Properties.Settings.Default.Save();
            }
        }

    }
}
